<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class GoodsRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'cate_id'=>'required',
            'name'=>'required',
            'detail'=>'required',
            'price'=>'required | numeric',
            'reprice'=>'required | numeric',
            'num'=>'required',
            'thumb'=>'required',
            'pic'=>'required'
        ];
    }
    public function messages(){
        return [
            'name.required'=>'商品名称不能为空',
            'cate_id.required'=>'分类不能为空',
            'detail.required'=>'商品详情不能为空',
            'price.required'=>'商品现价不能为空',
            'price.numeric'=>'商品现价只能是数字',
            'reprice.required'=>'商品原价不能为空',
            'reprice.numeric'=>'商品原价只能是数字',
            'num.required'=>'商品库存不能为空',
            'num.numeric'=>'商品库存只能是数字',
            'thumb.required'=>'商品缩略图不能为空',
            'pic.required'=>'商品主图不能为空',
        ];
    }
}
